The present invention relates to a digital video transcoder and method for allocating bits for encoding successive pictures in a group of pictures (GOP) without a priori knowledge of the picture types in the GOP.
With digital video coding standards such as MPEG, input pictures can be coded in three different picture types, namely I, P and B. The three pictures require quite different numbers of bits for encoding because of the different nature of their temporal processing. Hence, an intelligent bit is allocation strategy should assign a number of bits for encoding according to the picture""s type. This implies a requirement of a priori knowledge of the picture types for a given bit budget. This requirement is not a problem for a standalone encoder as the encoder can determine the picture type for each input picture.
In fact, the encoder can plan ahead for the types of the input pictures. In contrast, a transcoder has no such a priori knowledge regarding a picture""s type before actually processing the picture. This creates difficulty in allocating an appropriate number of bits for encoding pictures in a transcoder.
Accordingly, it would be desirable to have a method and apparatus for allocating bits for encoding pictures in a transcoder without a priori knowledge of the picture type. The system should avoid a processing delay of about one GOP which would otherwise be incurred to extract the complete GOP structure information from a pre-compressed bit stream. In addition, the system should avoid the need to store the data corresponding to the GOP, thereby reducing the memory required for transcoding.
The system should be compatible with both variable bit rate and constant bit rate bitstreams.
The system should be compatible with statistical multiplexing and remultiplexing systems.
The present invention provides an apparatus and method having the above and other advantages.
The present invention relates to a digital video transcoder and method for allocating bits for encoding successive pictures in a group of pictures (GOP) without a priori knowledge of the arrangement of picture types in the GOP.
A method for allocating bits for coding a progressive refresh sequence of pictures in a bitstream received at a digital video transcoder includes the steps of: (a) providing an assumed distance Mxe2x80x2 between a first picture of the bitstream and the next closest subsequent P-picture of the bitstream (in display order); (b) providing an assumed bit budget as a function of the assumed distance Mxe2x80x2; (c) coding the first picture in accordance with the assumed bit budget; (d) determining a picture type of a second picture that immediately follows the first picture in the bitstream; (e) adjusting the assumed bit budget according to the picture type of the second picture; and (f) allocating bits for coding the second picture in accordance with the adjusted bit budget.
Thus, a bit budget for coding the pictures is initially assumed for the first picture, and the bit budget is updated as the second picture type is known. A target number of bits is allocated for coding each picture according to the bit budget. The first and second picture types generally indicate the picture distribution in the sequence.
The assumed bit budget is proportional to the assumed distance and a bit rate of the bitstream, and inversely proportional to a frame rate of the bitstream.
The pictures in the bitstream may form a progressive refresh sequence, where there is no GOP structure.
1.1 P-picture Followed by B-picture
When the first picture is a P-picture and the second picture is a B-picture, the method includes the further step of: determining an actual distance Mxe2x80x3 between the first picture and the next closest subsequent P-picture (in display order) according to the picture type of the first picture and the picture type of the second picture.
The actual distance Mxe2x80x3 is determined according to a difference between a temporal reference of the first picture, in a display order of the bitstream, and a temporal reference of the second picture, in the display order, plus one picture.
The method may include the further step of allocating bits for coding the remaining Mxe2x80x3xe2x88x921 pictures following the first picture in accordance with the adjusted bit budget.
The assumed bit budget is adjusted in the adjusting step (f) by +(Mxe2x80x3xe2x88x92Mxe2x80x2)*xe2x80x9cbit ratexe2x80x9d/xe2x80x9cframe ratexe2x80x9d, where xe2x80x9cbit ratexe2x80x9d is a bit rate of the bitstream, and xe2x80x9cframe ratexe2x80x9d is a frame rate of the bitstream.
1.2 P-picture Followed by P-picture
When the first and second pictures are P-pictures, the method includes the further step of: determining an actual distance Mxe2x80x3 between the first picture and the next closest subsequent P-picture (in display order) according to the picture type of the first picture and the picture type of the second picture. The actual distance Mxe2x80x3 is determined according to a difference between a temporal reference of the second picture and a temporal reference of the first picture. The temporal references are determined in relation to a display order of the bitstream.
The assumed bit budget is adjusted in the adjusting step (f) by xe2x88x92(Mxe2x80x2xe2x88x921)*xe2x80x9cbit ratexe2x80x9d/xe2x80x9cframe ratexe2x80x9d, where xe2x80x9cbit ratexe2x80x9d is a bit rate of the bitstream, and xe2x80x9cframe ratexe2x80x9d is a frame rate of the bitstream.
The method includes the further step of allocating bits for coding a series of Mxe2x80x3 pictures following an initial Mxe2x80x3 pictures that includes the first and second pictures in the bitstream in accordance with the adjusted bit budget. Thus, the adjustments to the bit budget in one series of pictures is carried over to the next series to allow correct coding of the next series.
Generally, the invention enables transcoding to begin by assuming a reasonable set of GOP parameters, including M, the distance between each I-picture and the next P-picture, and N, the GOP length. M and N are adjusted during transcoding as additional information becomes available regarding the GOP structure, e.g., the distribution of picture types in the GOP and the length of the GOP.
The assumed M can be corrected to the actual value within two frames, and the assumed N can be corrected to the actual value within one GOP. M should be verified, and adjusted if necessary, after each I- or P-picture, and N should be verified, and adjusted if necessary, after each I-picture. When M and/or N are adjusted, a bit rate R for coding the pictures, and nI, nP, and nB, the remaining numbers of I, P and B-pictures in the current GOP, respectively, are also adjusted.
A method for allocating bits for coding a non-progressive refresh sequence of pictures in a bitstream received at a digital video transcoder, includes the steps of: (a) providing an assumed length Nxe2x80x2 of a particular group of pictures (GOP) of the bitstream; (b) providing an assumed bit budget as a function of the assumed length Nxe2x80x2; providing an assumed distance Mxe2x80x2 between the first picture and the next closest subsequent P-picture of the bitstream (in display order); (c) allocating bits for coding a first picture of the particular GOP in accordance with the assumed bit budget, and Nxe2x80x2 and Mxe2x80x2; (d) determining a picture type of a second picture that immediately follows the first picture; (e) adjusting the assumed bit budget according to the picture type of the second picture; and (f) allocating bits for coding the second picture in accordance with the adjusted bit budget.
The assumed bit budget is proportional to the assumed length Nxe2x80x2 and a bit rate of the bitstream, and inversely proportional to a frame rate of the bitstream.
Mxe2x80x3 may change within a GOP. Thus, the method may include the step of periodically verifying Mxe2x80x3 throughout the GOP. For example, Mxe2x80x3 may be calculated at every I-picture and/or P-picture that follows the first I-picture. The assumed bit budget is adjusted each time in accordance with Mxe2x80x3.
2.1 I-picture Followed by I-picture
When the first and second pictures are I-pictures, the method comprises the further step of: determining an actual distance Mxe2x80x3 between the first picture and the next closest subsequent I-picture of the bitstream according to the picture type of the second picture, and adjusting the assumed bit budget in accordance with Mxe2x80x3.
The actual distance Mxe2x80x3 is determined according to a difference between a temporal reference of the second picture, in a display order of the bitstream, and a temporal reference of the first picture, in the display order.
The adjusting step (e) comprises the step of: adjusting the assumed bit budget by xe2x88x92(Nxe2x80x2xe2x88x921)*xe2x80x9cbit ratexe2x80x9d/xe2x80x9cframe ratexe2x80x9d, where xe2x80x9cbit ratexe2x80x9d is a bit rate of the bitstream, xe2x80x9cframe ratexe2x80x9d is a frame rate of the bitstream, and N=M=Mxe2x80x3.
The method comprises the further step of: allocating bits for coding the remaining pictures in the particular GOP following the second picture in accordance with the adjusted bit budget.
2.2 I-picture Followed by P-picture
When the first picture is an I-picture and the second picture is a P-picture, the method comprises the further steps of: determining an actual distance Mxe2x80x3 between the first picture and the next closest subsequent P-picture (in display order) according to the picture type of the second picture; and adjusting the assumed length Nxe2x80x2 of the GOP in accordance with the actual distance Mxe2x80x3 to provide an adjusted assumed length Nxe2x80x3; wherein: the adjusting step (e) is responsive to the adjusted assumed length Nxe2x80x2.
The assumed length Nxe2x80x2 of the particular GOP is adjusted in the adjusting step thereof by a factor, M(Nxe2x80x2/Mxe2x80x3), where M=Mxe2x80x3, to provide the adjusted assumed length Nxe2x80x3.
The adjusting step (e) comprises the step of: adjusting the assumed bit budget by a factor (Nxe2x80x3xe2x88x92Nxe2x80x2)*xe2x80x9cbit ratexe2x80x9d/xe2x80x9cframe ratexe2x80x9d, where xe2x80x9cbit ratexe2x80x9d is a bit rate of the bitstream, and xe2x80x9cframe ratexe2x80x9d is a frame rate of the bitstream.
The adjusting step (e) comprises the still further step of: adjusting the assumed bit budget by a factor, (Mxe2x80x3xe2x88x921xe2x80x2)*xe2x80x9cbit ratexe2x80x9d/xe2x80x9cframe ratexe2x80x9d, where xe2x80x9cbit ratexe2x80x9d is a bit rate of the bitstream, xe2x80x9cframe ratexe2x80x9d is a frame rate of the bitstream, and M=Mxe2x80x3.
Thus, both the GOP length and the distance M are used to adjust the bit budget, which in turn affects the target bit allocation for each picture.
The method includes the further step of allocating bits for coding the remaining pictures in the particular GOP following the second picture in accordance with the adjusted bit budget.
The method includes the further steps of determining if Nxe2x80x3 greater than N or Nxe2x80x3 less than N, where N is an actual length of the current GOP, after coding Nxe2x80x3 pictures in the current GOP. This is accomplished by observing the picture that is reached after coding Nxe2x80x3 pictures. For example, if the picture reached after coding Nxe2x80x3 pictures is a P-picture in the current GOP, then Nxe2x80x3 less than N. If the picture reached after coding Nxe2x80x3 pictures is an I-picture, this signals the start of the next GOP, so Nxe2x80x3=N. If an I-picture is coded before the Nxe2x80x3 are all coded, this indicates Nxe2x80x3 greater than N. The already adjusted bit budget is then further adjusted based on whether Nxe2x80x3 less than N or Nxe2x80x3 greater than N, and bits are allocated for coding pictures in the bitstream following the Nxe2x80x3 coded pictures according to the further adjusted bit budget.
2.3 I-picture Followed by B-picture
When the first picture is an I-picture and the second picture is a B-picture, the method comprises the further steps of: determining an actual distance Mxe2x80x3 between the first picture and the next closest subsequent P-picture (in display order) according to the picture type of the second picture; and adjusting the assumed length Nxe2x80x2 of the GOP in accordance with the actual distance Mxe2x80x3 to provide an adjusted assumed length Nxe2x80x3; wherein: the adjusting step (e) is responsive to the adjusted assumed length Nxe2x80x2.
The assumed length Nxe2x80x2 of the particular GOP is adjusted in the adjusting step thereof by a factor, M(Nxe2x80x2/Mxe2x80x3), where M=Mxe2x80x3, to provide the adjusted assumed length Nxe2x80x3.
The adjusting step (e) comprises the step of: adjusting the assumed bit budget by a factor (Nxe2x80x3xe2x88x92Nxe2x80x2)*xe2x80x9cbit ratexe2x80x9d/xe2x80x9cframe ratexe2x80x9d, where xe2x80x9cbit ratexe2x80x9d is a bit rate of the bitstream, and xe2x80x9cframe ratexe2x80x9d is a frame rate of the bitstream.
The method comprises the further steps of: allocating bits for coding the remaining pictures in the particular GOP following the second picture in accordance with the adjusted bit budget.
Additionally, as discussed above, the already adjusted bit budget may be further adjusted based on whether Nxe2x80x3 less than N or Nxe2x80x3 greater than N, and bits may be allocated for coding pictures in the bitstream following the Nxe2x80x3 coded pictures according to the further adjusted bit budget.
Thus, the information learned regarding GOP length and M, the distance between I and/or P-pictures, in one GOP are used in coding the following GOPs. Target rates with incorrect starting GOP parameters will converge within a few GOPs.
Corresponding apparatus structures are also presented.